﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using UIFramework;

namespace FieldServices
{
    public partial class frmOperation : UIForm
    {
        public frmOperation()
        {
            InitializeComponent();
        }
        private string _OperationID;
        private string _OrderID;
        private DataTable dt;
        public frmOperation(string OrderID)
        {
            this._OrderID = OrderID;
            InitializeComponent();
            DisplayOperation(_OrderID);
        }
        private void DisplayOperation(string OrderID)
        {
            lblOrder.Text = OrderID;       
            DataTable _dt = new DataTable();
            _dt.Columns.Add("ACTIVITY", typeof(string));
            _dt.Columns.Add("START_CONS", typeof(string));
            _dt.Columns.Add("DESCRIPTION", typeof(string));
            DataGridTextBoxColumn ColOrder = new DataGridTextBoxColumn();
            ColOrder.MappingName = "ACTIVITY";
            ColOrder.HeaderText = "Activity";
            ColOrder.Width = 120;
            ColOrder.Format = "c";

            DataGridTextBoxColumn ColCustomer = new DataGridTextBoxColumn();
            ColCustomer.MappingName = "START_CONS";
            ColCustomer.HeaderText = "Date";
            ColCustomer.Width = 260;
            ColCustomer.Format = "c";

            DataGridTextBoxColumn ColStatus = new DataGridTextBoxColumn();
            ColStatus.MappingName = "DESCRIPTION";
            ColStatus.HeaderText = "Description";
            ColStatus.Width = 80;
            ColStatus.Format = "c";

            DataSet ds = Common.dsItems;
            dt = ds.Tables[2];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
 
                DataRow dr = _dt.NewRow();
                dr[0] = dt.Rows[i]["ACTIVITY"].ToString();
                dr[1] = dt.Rows[i]["START_CONS"].ToString();
                dr[2] = dt.Rows[i]["DESCRIPTION"].ToString();
                _dt.Rows.Add(dr);

            }
            DataGridTableStyle aGridTableStyle = new DataGridTableStyle();
            aGridTableStyle.GridColumnStyles.Add(ColOrder);
            aGridTableStyle.GridColumnStyles.Add(ColCustomer);
            aGridTableStyle.GridColumnStyles.Add(ColStatus);
            _dt.TableName = "OperationItems";
            dtgOperation.DataSource = _dt;
            dtgOperation.TableStyles.Add(aGridTableStyle);
            aGridTableStyle.MappingName = "OperationItems";
  
    }

        private void dtgOperation_DoubleClick(object sender, EventArgs e)
        {
            int row = dtgOperation.CurrentRowIndex;
            string orderID = dt.Rows[row]["OrderID"].ToString();
            frmResourceList frm = new frmResourceList(orderID);
            frm.Show();
        }

    }
}